<?xml version="1.0" encoding="utf-8"?>
<openerp>
	<data>

<!--Purchase Inherit-->

		<record id="purchase_order_form_applico" model="ir.ui.view">
			<field name="name">purchase.order.form.applico</field>
			<field name="model">purchase.order</field>
			<field name="inherit_id" ref="purchase.purchase_order_form"/>
			<field name="arch" type="xml">
				<button name="wkf_send_rfq" states="approved" position="replace">
					<button name="wkf_send_rfq" invisible="1" string="Send PO by Email" type="object" context="{'send_rfq':False}"/>
				</button>
				<field name="shipped" position="replace">
					<field name="shipped" invisible="1"/>
					<field name="shipped_rate"/>
					<field name="all_service"/>
				</field>
				<field name="invoiced" position="replace">
					<field name="invoiced" invisible="1"/>
				</field>
				<button name="view_picking" position="before">
					<button type="object"
						name="recreate_picking"
						string="Recreate Incoming" class="oe_highlight" states="approved" groups="purchase.group_purchase_manager"/>
					<button type="object"
						name="recreate_invoice"
						string="Recreate Invoices" class="oe_highlight" attrs="{'invisible': ['|',('invoice_method','not in', ('order')), ('state','not in', ('approved'))]}"/>
				</button>
				<button name="action_cancel" position="replace">
					<button name="action_cancel" states="draft,confirmed,sent,bid,approved,except_picking,except_invoice" string="Cancel" type="object" groups="purchase.group_purchase_manager"/>
				</button>
				<field name="state" position="replace">
					<field name="state" widget="statusbar" statusbar_visible="draft,approved" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/>
				</field>
				<button name="view_picking" position="replace">
					<button name="view_picking" string="Receive Products" type="object" invisible="1" class="oe_highlight"/>
				</button>
				<button name="view_invoice" position="replace">
					<button name="view_invoice" string="Receive Invoice" type="object" invisible="1" attrs="{'invisible': ['|', ('invoice_method','in', ['picking', 'manual']), '|', ('state','!=', 'approved'), ('invoiced','=',True) ]}" class="oe_highlight"/>
				</button>
				<field name="currency_id" position="replace">
					<field name="currency_id" invisible="1"/>
				</field>
				<field name="order_line" position="replace">
					<field name="order_line">
                        <tree string="Purchase Order Lines" editable="bottom">
                            <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,False,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,False,parent.state,context)"/>
                            <field name="name"/>
                            <field name="date_planned"/>
                            <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
                            <field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('type','not in',('view','template'))]"/>
                            <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,False,parent.state,context)"/>
                            <field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,False,parent.state,context)"/>
                            <field name="price_unit"/>
                            <field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
                            <field name="price_subtotal"/>
                            <field name="state" invisible="1"/>
                            <button name="%(edit_qty_po_line_act)d" string="Edit Qty" type="action" icon="gtk-go-forward" groups="applico_v8.group_purchase_approved_edit_line"/>
                            <button name="%(act_delete_po_line)d" string="Delete Line" type="action" icon="gtk-cancel" groups="applico_v8.group_purchase_approved_delete_line"/>
                            
                        </tree>
                    </field>
				</field>
				
				<page string="Deliveries &amp; Invoices" position="after">
					<page string="Other Setup" groups="applico_v8.group_purchase_approved_add_line">
						<group>
							<button type="action"
	                            name="%(act_add_lines_po)d"
	                            class="oe_stat_button"
	                            icon="fa-sign-in"
	                            string="Add PO Line" states="confirmed,approved">
	                        </button>
						</group>
					</page>
				</page>
			</field>
		</record>


<!-- Purchase Order Line Inherit -->
		<record id="purchase_order_line_search_applico" model="ir.ui.view">
			<field name="name">ppurchase.order.line.search.applico</field>
			<field name="model">purchase.order.line</field>
			<field name="inherit_id" ref="purchase.purchase_order_line_search"/>
			<field name="arch" type="xml">
				<field name="partner_id" position="after">
					<filter icon="terp-check" name="non_invoiced" string="Non Invoiced" domain="[('invoiced', '=', False)]"/>
				</field>
			</field>
		</record>

		<record id="purchase.purchase_line_form_action2" model="ir.actions.act_window">
			<field name="domain">[('order_id.invoice_method','=','manual'), ('state','in',('confirmed','done'))]</field>
			<field name="context">{"search_default_non_invoiced": 1}</field>
		</record>

		<record id="purchase_order_line_form2_applico" model="ir.ui.view">
			<field name="name">purchase.order.line.form2.applico</field>
			<field name="model">purchase.order.line</field>
			<field name="inherit_id" ref="purchase.purchase_order_line_form2"/>
			<field name="arch" type="xml">
				<xpath expr="//sheet/h1" position="after">
					<div class="oe_right oe_button_box" name="buttons">
						<button name="revert_invoice" attrs="{'invisible':[('invoiced','=',False)]}" string="Revert To non Invoiced" type="object"/>
					</div>
				</xpath>
				<field name="order_id" position="replace">
					<field name="order_id" class="oe_inline" readonly="1" domain="[('invoice_method','=','manual')]" />
				</field>
				<field name="price_unit" position="replace">
					<field name="price_unit" readonly="1"/>
				</field>
			</field>
		</record>

		<record id="purchase_order_line_form_applico" model="ir.ui.view">
			<field name="name">purchase.order.line.form.applico</field>
			<field name="model">purchase.order.line</field>
			<field name="inherit_id" ref="purchase.purchase_order_line_form"/>
			<field name="arch" type="xml">
				<field name="price_unit" position="replace"/>
				<field name="product_uom" position="replace"/>
				<field name="product_qty" position="replace"/>
				<label for="product_qty" position="replace"/>
				<field name="product_id" position="replace">
					<field name="product_id" readonly="1" on_change="onchange_product_id(parent.pricelist_id,product_id,0,False,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,False,'draft',context)"/>
					<label for="product_qty" readonly="1"/>
					<div>
						<field name="product_qty" readonly="1" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,False,'draft',context)" class="oe_inline"/>
						<field name="product_uom" readonly="1" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,False,'draft',context)" class="oe_inline"/>
					</div>
					<field name="price_unit" readonly="1"/>
				
				</field>
				<field name="company_id" position="replace"/>
				<field name="account_analytic_id" position="replace"/>
				<field name="date_planned" position="replace"/>
				<field name="taxes_id" position="replace">
					<field name="taxes_id" readonly="1" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
					<field name="date_planned" readonly="1" widget="date"/>
					<field name="account_analytic_id" readonly="1" colspan="2" groups="purchase.group_analytic_accounting"/>
					<field name="company_id" readonly="1" groups="base.group_multi_company" widget="selection"/>
				</field>
				<field name="name" position="replace">
					<field name="name" readonly="1"/>
				</field>
			</field>
		</record>

		<act_window name="Merge Purchase orders"
			context="{'search_default_draft': 1, 'search_default_approved': False}"
			res_model="purchase.order.group"
			src_model="purchase.order"
			view_mode="form"
			target="new"
			multi="True"
			groups="hidden_applico"
			key2="client_action_multi"
			id="purchase.action_view_purchase_order_group"/>

		<record id="purchase.menu_procurement_management_inventory" model="ir.ui.menu">
			<field name="groups_id" eval="[(6,0,[ref('hidden_applico')])]"/>
		</record>
		<record id="purchase.menu_purchase_line_order_draft" model="ir.ui.menu">
			<field name="groups_id" eval="[(6,0,[ref('hidden_applico')])]"/>
		</record>
		
		<delete model="ir.values" search="[('name','=','action_view_purchase_line_invoice')]"/>
	</data>
</openerp>


